<template>
<div class="Equ_table" >
 <el-autocomplete
  v-model="state"
  :fetch-suggestions="querySearchAsync"
  placeholder="请输入内容"
  @select="handleSelect"
  
></el-autocomplete>
  <el-row>
    <el-button type="primary">
      <i class="el-icon-search"></i>
      搜索
    </el-button>
  </el-row>
  


  <el-table :data="tableData" style="width: 100%">
    <el-table-column label="编号" align="center" >
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.id }}</span>
      </template>
    </el-table-column>

    <el-table-column label="表单名称" align="center" >
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.name }}</span>
      </template>
    </el-table-column>

    <el-table-column label="申请日期" align="center">
      <template slot-scope="scope">
        <i class="el-icon-time"></i>
        <span style="margin-left: 10px">{{ scope.row.date }}</span>
      </template>
    </el-table-column>

    <el-table-column label="操作" align="center">
      <template slot-scope="scope">
        <el-button  size="mini" type="primary" @click="handleEdit(scope.$index, scope.row)">查看</el-button>
        <el-button :disabled="scope.row.disabled" size="mini" type="success" @click="open">归还</el-button>
            
      </template>
    </el-table-column>
    
  </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400">
    </el-pagination>
  </div>
</template>

<script>
export default {
     data() {
      return {
        // 搜索
        restaurants: [],
        state: '',
        timeout:  null,

      // 表单
         tableData: [{
          id:'1',
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          id:'2',
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄'
        }],

        // 弹窗
        disabled:false
      };
    },
    methods: {
      // 弹框
      open() {
        
        this.$confirm('此操作将归还设备,是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '归还成功!',
            

          });
           
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消归还'
          });          
        });
      },

      // 表单
      handleEdit(index, row) {
        console.log(index, row);
      },
      handleDelete(index, row) {
        console.log(index, row);
      },

      // 搜索
      loadAll() {
        return [
         { "value": "速记黄焖鸡米饭", "address": "上海市长宁区北新泾街道金钟路180号1层01号摊位" },
          { "value": "红辣椒麻辣烫", "address": "上海市长宁区天山西路492号" },
          { "value": "(小杨生煎)西郊百联餐厅", "address": "长宁区仙霞西路88号百联2楼" },
          { "value": "阳阳麻辣烫", "address": "天山西路389号" },
          { "value": "南拳妈妈龙虾盖浇饭", "address": "普陀区金沙江路1699号鑫乐惠美食广场A13" }
        ];
      },
      querySearchAsync(queryString, cb) {
        var restaurants = this.restaurants;
        var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;

        clearTimeout(this.timeout);
        this.timeout = setTimeout(() => {
          cb(results);
        }, 3000 * Math.random());
      },
      createStateFilter(queryString) {
        return (state) => {
          return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
        };
      },
      handleSelect(item) {
        console.log(item);
      }
    },
    mounted() {
      this.restaurants = this.loadAll();
    },
   
    }
  
</script>

<style scoped>
.Equ_table {
  position: relative;
  height: 100%;
  background-color: #fff;
} 
.el-table-column {
  background-color: rgb(201, 29, 29);
}
.el-row {
  display: inline-block;
  margin-left: 20px;
}
.el-autocomplete {
  display: inline-block;
  margin-left: -800px;
  margin-bottom: 20px;
  margin-top: 20px;
}
.el-pagination {
  margin-top: 40%;
}
#guihuan {
  width: 60px;
  
}
.el-button--text {
  color: #fff;
}
</style>